/*  quadrant derived class for ND++ minesweeeper game
Programmer:  Prof. Scott

This contains the implementation of the class that will be used as the cell type that does not 
hold a bomb for our game

Please refer to quadrant.h for details about this class.

Special note:  one design decision that was made was that the constructor should be very 
simple and as such bombNeighbors should be a known default value.  We will set it to be
-1 in the constructor that will be used for the board class as proof this cell was clicked for 
the first time.  It will then recursively branch out from this cell if there are no neighoring
cells that are bombs (and therefore all 8 neighbors can be "clicked")  Please see board.cpp
for details on this search/expand algorithm that determines as many quadrant cells as possible
and uses setNeighbors to fill in the quadrant with the appropriate number.

*/

#include <iostream>
#include "quadrant.h"

// default constructor; sets neighboring bomb value to be -1
Quadrant::Quadrant () : bombNeighbors (-1) {}

// display function; if getneighbors == 0, displays a space; if getNeigbors > 0 it displays that number; otherwise "="
void Quadrant::display () {

  int neighbors = getNeighbors();
  if (neighbors >= 0) {

    if (neighbors == 0)      // no neighbors possible 
      std::cout << "  ";
    else 
      std::cout << neighbors << " ";   // display the neighbors

  }
  else {

    if (checkIfFlagged() == 1)   // cell flagged
      std::cout << "@ ";
    else
      std::cout << "= ";      // cell unflagged

  }

}

// get function for private neighbors value
int Quadrant::getNeighbors() {

  return (bombNeighbors);

}

// set function for bombNeigbors; does nothing if value is < 0 or > 8
void Quadrant::setNeighbors(int newValue) {

  if (newValue >= 0 && newValue <= 8)
    bombNeighbors = newValue;

}

  
